//
//  System.hpp
//  Simulation
//
//  Created by Christopher Kemsley on 2/24/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef Simulation_System_hpp
#define Simulation_System_hpp

#include "Types.hpp"
#include <set>

NamespaceBegin






class	System ;
class	SystemController ;



class	System
{
public:
	
	static System&	shared() ;
	
	
	
	Interval const&	currentTime () const ;
	
	
	void	runForDuration	( Interval const & duration ) ;
	
	
	
	
private:
	Interval	mCurrentTime ;
	
	System () ;
	~System () ;
	
protected:
	friend class SystemController ;
	
	std::set<SystemController*>	mControllers ;
} ;








// Note: system controllers should always be singletons and should never be deleted
class	SystemController
{
protected:
	virtual Interval const	minimumTimeInterval () const = 0 ;
	
	virtual void	systemWillAdvance	( Interval const & from , Interval const & to , bool isZeroTime ) { } ;
	virtual void	systemDidAdvance	( Interval const & from , Interval const & to , bool isZeroTime ) { } ;
	
	SystemController () ;
	
	friend class System ;
} ;







NamespaceEnd
#endif
